<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click='num++'>点击了{{num}}次</button>
        <counter></counter>
        <counter></counter>
        <counter></counter>
        <counter></counter>
        <button-counter></button-counter>
        <button-counter></button-counter>

    </div>
    <script src="/node_modules/vue/dist/vue.js"></script>
    <script>
        //1、全局声明、注册组件
        Vue.component('counter', {
            template:`<button @click='num++'>点击了{{num}}次===</button>`,
            data(){
                return {
                    num:1
                }
            }
        })
        // 2、局部声明组件
        const buttonCounter = {
            template:`<button @click='num++'>点击了{{num}}次---</button>`,
            data(){
                return {
                    num:1
                }
            }
        }
        new Vue({
            el: '#app',
            // 局部组件的引入
            components:{
                // 'button-counter':buttonCounter
                buttonCounter // 约定为 button-counter
            },
            data() {
                return {
                    num: 0
                }
            }
        })
    </script>
</body>

</html>